*Table1

use ../Metadata/tess_analysisdata.dta, clear

********************************************************************************
* Create excel shell

cd ../Results
putexcel set "Table1-SummaryStats.xlsx", replace

putexcel A1 = "Table 1. Descriptive Statistics (Means/Proportions)", bold
putexcel B2 = "Studies"
putexcel C2 = "Hypotheses"

* sample size
		putexcel A3 = "Sample size"
		
		sum samplesize if hyp_num==1 
		putexcel B3 = `r(mean)', nformat(number)	
		scalar sd = round(`r(sd)')
		putexcel B4 = "(SD = `=sd')", nformat(number_d2)		
	
		sum N_person if insample==1
		putexcel C3 = `r(mean)', nformat(number)	
		scalar sd = round(`r(sd)')
		putexcel C4 = "(SD = `=sd')", nformat(number_d2)				

* measurement
		putexcel A5 = "Dependent variable measurement", italic
		putexcel A6 = "     Multi-item measure"
		putexcel B6= "N/A"
		
		recode num_measures (1=0) (2/50=1), gen(singleitem)
		sum singleitem if insample==1
		putexcel C6 = `r(mean)', nformat(number_d2)

		putexcel A7 = "     Binary measure"
		putexcel B7= "N/A"
		
		recode outcome_categories (2=1) (3/8=0), gen(binarydv)
		sum binarydv  if insample==1
		putexcel C7 = `r(mean)', nformat(number_d2)

	
	
* type of test
		putexcel A8 = "Hypothesis test type", italic

		putexcel A9 = "     Default treatment comparison"
		putexcel B9= "N/A"
		sum hyp_default  if insample==1
		putexcel C9 =  `r(mean)', nformat(number_d2)

		putexcel A10 = "     Moderation"
		putexcel B10= "N/A"
		sum moderation  if insample==1
		putexcel C10 =  `r(mean)', nformat(number_d2)


		putexcel A11 = "     Mediation"
		putexcel B11= "N/A"
		sum mediation  if insample==1
		putexcel C11 = `r(mean)', nformat(number_d2)

		
* experiment type
		putexcel A12 = "Experiment type", italic

		putexcel A13 = "     Vignette"
		sum type_vignette if hyp_num==1 
		putexcel B13 = `r(mean)', nformat(number_d2)
		sum type_vignette  if insample==1
		putexcel C13 = `r(mean)', nformat(number_d2)		

		putexcel A14 = "     Priming"
		sum type_priming if hyp_num==1 
		putexcel B14 = `r(mean)', nformat(number_d2)
		sum type_priming  if insample==1
		putexcel C14 = `r(mean)', nformat(number_d2)		
		
		putexcel A15 = "     Framing"
		sum type_framing if hyp_num==1 
		putexcel B15 = `r(mean)', nformat(number_d2)
		sum type_framing  if insample==1
		putexcel C15 = `r(mean)', nformat(number_d2)

		putexcel A16 = "     Question-wording"
		sum type_questwording if hyp_num==1 
		putexcel B16 = `r(mean)', nformat(number_d2)
		sum type_questwording  if insample==1
		putexcel C16 = `r(mean)', nformat(number_d2)

		putexcel A17 = "     Information provision"
		sum type_information if hyp_num==1 
		putexcel B17 = `r(mean)', nformat(number_d2)
		sum type_information  if insample==1
		putexcel C17= `r(mean)', nformat(number_d2)


		putexcel A18 = "     Belief elicitation"
		sum type_beliefelicit if hyp_num==1 
		putexcel B18 = `r(mean)', nformat(number_d2)
		sum type_beliefelicit  if insample==1
		putexcel C18 = `r(mean)', nformat(number_d2)


		putexcel A19 = "     Conjoint/Discrete-choice"
		sum type_conj_dce if hyp_num==1 
		putexcel B19 = `r(mean)', nformat(number_d2)
		sum type_conj_dce  if insample==1
		putexcel C19 = `r(mean)', nformat(number_d2)

		putexcel A20 = "     Writing treatment"
		sum type_writing if hyp_num==1 
		putexcel B20 = `r(mean)', nformat(number_d2)		
		sum type_writing  if insample==1
		putexcel C20 = `r(mean)', nformat(number_d2)


// PI attributes

		putexcel A21 = "Faculty PI"
		recode title (1/2 6 =0) (3/5=1), gen(faculty)
		sum faculty if hyp_num==1
		putexcel B21 =  `r(mean)', nformat(number_d2)
		sum faculty  if insample==1
		putexcel C21 =  `r(mean)', nformat(number_d2)
		
		putexcel A22 = "Co-authored"
		recode numauthors (1=0) (2/4=1), gen(coauthored)
		sum coauthored if hyp_num==1
		putexcel B22 =  `r(mean)', nformat(number_d2)
		sum coauthored  if insample==1
		putexcel C22 =  `r(mean)', nformat(number_d2)

		putexcel A23 = "Political science"
		gen polsci = (discipline == 5)
		sum polsci if hyp_num==1
		putexcel B23 =  `r(mean)', nformat(number_d2)
		sum polsci  if insample==1
		putexcel C23 =  `r(mean)', nformat(number_d2)


* other study characrteristics
		putexcel A24 = "Pilot conducted"
		sum pilot if hyp_num==1 
		putexcel B24 = `r(mean)', nformat(number_d2)
		sum pilot  if insample==1
		putexcel C24 = `r(mean)', nformat(number_d2)

		putexcel A25 = "Attention or manipulation check"
		sum any_checks if hyp_num==1 
		putexcel B25 = `r(mean)', nformat(number_d2)
		sum any_checks  if insample==1
		putexcel C25 = `r(mean)', nformat(number_d2)

* count
	putexcel A26 = "Count"
	putexcel B26 = 100
	sum samplesize 
	putexcel C26 = `r(N)'
	putexcel B26:C26, overwritefmt nformat(##0)
	
* note
	putexcel A27 = "Note: SD = standard deviation. Sample excludes no-difference and non-experimental hypotheses."

* table format
	putexcel (A1:C2), border(bottom)
	putexcel (A25:C25), border(bottom)
	putexcel (A26:C26), border(bottom)
	putexcel (A1:C46), font(timesnewroman, 11)

cd ../Script
